package jd.com;

import javax.swing.*;
import java.awt.*;

/**
 * Created by wangpengzhi1 on 2018/7/5.
 */
public class OperUI extends JFrame{

    public static void main(String[] args){
        OperUI ui = new OperUI();
        ui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        ui.setSize(1200,600);
        ui.setResizable(false);
        try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        }catch (Exception e){
            e.printStackTrace();
        }
        ui.setLayout(new BorderLayout());

        JPanel jp_param = new JPanel();
        JButton jb_submitTest = new JButton("导入左侧数据集");
        jb_submitTest.setActionCommand("importStudent");
        JButton jb_submit = new JButton("导入右侧据集");
        jb_submit.setActionCommand("importPool");
        JButton jb_byId = new JButton("开始比对");
        jb_byId.setActionCommand("byId");
        JButton jb_reset = new JButton("右侧数据重置");
        jb_reset.setActionCommand("reset");
        JButton jb_resetS = new JButton("左侧数据重置");
        jb_resetS.setActionCommand("resetS");

        JButton jb_check = new JButton("校验身份证号码");
        jb_check.setActionCommand("checkData");


        jp_param.add(jb_resetS);
        jp_param.add(jb_submitTest);
        jp_param.add(jb_submit);
        jp_param.add(jb_check);
        jp_param.add(jb_byId);
        jp_param.add(jb_reset);

        JPanel jp = new JPanel();
        jp.add(jp_param);
        ui.add(jp,BorderLayout.NORTH);

        JPanel jp_log = new JPanel();
        jp_log.setLayout(new GridLayout(1,2));

        JTable jt_student = new JTable();
        jt_student.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        JTable jt_pool = new JTable();
        jt_pool.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

        JScrollPane jScrollPane1 = new JScrollPane(jt_student);
        jScrollPane1.setBorder(BorderFactory.createTitledBorder("左侧数据集"));
        JScrollPane jScrollPane2 = new JScrollPane(jt_pool);
        jScrollPane2.setBorder(BorderFactory.createTitledBorder("右侧数据集"));

        jp_log.add(jScrollPane1);
        jp_log.add(jScrollPane2);

        ui.add(jp_log);
        RunListener listener = new RunListener(jt_pool,jt_student,ui);
        jb_submit.addActionListener(listener);
        jb_reset.addActionListener(listener);
        jb_submitTest.addActionListener(listener);
        jb_byId.addActionListener(listener);
        jb_resetS.addActionListener(listener);
        jb_check.addActionListener(listener);
        ui.setVisible(true);
        ui.setTitle("巴林左旗丰水山寄宿制学校");
    }
}
